<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width:200px;
            margin: 200px auto;
        }
        .img{
            width: 200px;
        }
        @-webkit-keyframes zy{ 
            10% { 
            transform: rotate(15deg); 
            } 
            20% { 
            transform: rotate(-10deg); 
            } 
            30% { 
            transform: rotate(5deg); 
            } 
            40% { 
            transform: rotate(-5deg); 
            } 
            50%,100% { 
            transform: rotate(0deg); 
            } 
        }
        /* 使用 */
        .content {
            animation: zy 1.5s infinite;
        }

    </style>
</head>
<body>
    <div>
        <img class="img" src="./img/zongzi-icon8.png" alt="">
    </div>
    <script>
        let img = document.querySelector(".img");
        img.className = 'img content';
    </script>
</body>
</html>